package userTag

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method "PUT"
        url value(consumer(regex("api/programs/tags/\\d+")),
                producer("api/programs/tags/1"))
        body("""
            {   
                "name": "333",
                "creatorId": 1
            }
        """)
        bodyMatchers {
            jsonPath('$.name', byRegex(nonEmpty()))
            jsonPath('$.creatorId', byRegex(number()))
        }
        headers {
            contentType(applicationJsonUtf8())
        }
    }
    response {
        status 204
        body("""
            {   
                "name": "333",
                "creatorId": 1,
                "id": 1
            }
        """)
        bodyMatchers {
            jsonPath('$.id', byRegex(number()))
            jsonPath('$.name', byRegex(nonEmpty()))
            jsonPath('$.creatorId', byRegex(number()))
        }
        headers {
            contentType(applicationJsonUtf8())
        }
    }

}
